package com.company.cloud.art.client;

import com.company.cloud.art.modules.api.request.ArtistAddReq;
import com.company.cloud.art.modules.api.request.ArtistDelReq;
import com.company.cloud.art.modules.api.request.ArtistQueryReq;
import com.company.cloud.art.modules.api.request.ArtistUpdateReq;
import com.company.cloud.art.modules.api.response.ActSignUpQueryResp;
import com.company.cloud.art.modules.api.response.Artist;
import com.company.cloud.art.modules.api.response.ArtistQueryResp;
import com.company.cloud.art.modules.api.service.ArtArtistRemoteService;
import com.company.cloud.art.modules.mgr.service.ActArtistMgrService;
import com.company.cloud.art.modules.mgr.service.impl.ActArtistMgrServiceImpl;
import com.company.cloud.common.bean.BaseClientResult;
import com.company.cloud.common.bean.LoginSimpleUserInfo;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Log4j2
@RestController
@Service
public class ArtArtistRemoteServiceImpl implements ArtArtistRemoteService {

    @Autowired
    private ActArtistMgrService actArtistMgrService;


    @Override
    public BaseClientResult<ArtistQueryResp> artistQuery(ArtistQueryReq request) {
        try {
            return BaseClientResult.success(actArtistMgrService.artistQuery(request));
        }catch (Exception e){
            return BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<Artist> artistInfo(String artistNo) {
        try {
            return BaseClientResult.success(actArtistMgrService.artistInfo(artistNo));
        }catch (Exception e){
            return  BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<List<Artist>> artistInfoList(Set<String> artistNos) {
        try {
            List<Artist> data= actArtistMgrService.artistInfoList(artistNos);
            return BaseClientResult.success(data);
        }catch (Exception e){
            return  BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<Map<String, Artist>> artistInfoMap(Set<String> artistNos) {
        try {
            System.out.println("+++++++++++++++");
            Map<String,Artist> data= actArtistMgrService.artistInfoMap(artistNos);
            return BaseClientResult.success(data);
        }catch (Exception e){
            return  BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<String> artistAdd(ArtistAddReq request) {
        try {
            LoginSimpleUserInfo userInfo=new LoginSimpleUserInfo();
            userInfo.setId(request.getOpUserId());
            userInfo.setIp(request.getOpIp());
            actArtistMgrService.artistAdd(request,userInfo);
            return BaseClientResult.success();
        }catch (Exception e){
            return  BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<String> artistUpdate(ArtistUpdateReq request) {
        try {
            LoginSimpleUserInfo userInfo=new LoginSimpleUserInfo();
            userInfo.setId(request.getOpUserId());
            userInfo.setIp(request.getOpIp());
            actArtistMgrService.artistUpdate(request,userInfo);
            return BaseClientResult.success();
        }catch (Exception e){
            return  BaseClientResult.error(e);
        }
    }

    @Override
    public BaseClientResult<String> artistDel(ArtistDelReq request) {
        try {
            LoginSimpleUserInfo userInfo=new LoginSimpleUserInfo();
            userInfo.setId(request.getOpUserId());
            userInfo.setIp(request.getOpIp());
            actArtistMgrService.artistDel(request.getArtistNo(),userInfo);
            return BaseClientResult.success();
        }catch (Exception e){
            return  BaseClientResult.error(e);
        }
    }
}
